﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.system.basis
{
    public partial class sizelist : System.Web.UI.Page
    {
        Maticsoft.BLL.size bll = new Maticsoft.BLL.size();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request["id"] != "0" || string.IsNullOrEmpty(Request["id"]))
                {
                    string where = "cInvStd= '" + Request["id"] + "'";
                    hidwhere.Value = where;
                }
                hidcinvstd.Value = Request["id"];
                this.parentlist.DataSource = bll.GetList("parentcode is null or parentcode='' and cInvStd='" + hidcinvstd.Value + "'");
                this.parentlist.DataTextField = "name";
                this.parentlist.DataValueField = "code";
                this.parentlist.DataBind();
                this.parentlist.Items.Insert(0, new ListItem("--请选择所属尺寸--", ""));
                int totalOrders = bll.GetRecordCount(hidwhere.Value);
                AspNetPager1.RecordCount = totalOrders;
            }
        }
        protected string getcinvstd()
        {
            return hidcinvstd.Value;
        }
        void bindData(string where)
        {
            Repeater1.DataSource = bll.GetListByPage(where, "code", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
            Repeater1.DataBind();
        }
        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            bindData(hidwhere.Value);
        }
        protected string getparentname(string parentcode)
        {
            if (string.IsNullOrEmpty(parentcode))
                return "--";
            else
                return bll.GetModelList("parentcode='" + parentcode + "'")[0].name;
        }
        protected void btnserach_Click(object sender, EventArgs e)
        {
            string where = "cInvStd='" + hidcinvstd.Value + "'";
            if (parentlist.SelectedItem.Value != "")
            {
                where += " and parentcode = '" + parentlist.SelectedItem.Value + "'";
            }
            if (name.Value != null && !string.IsNullOrEmpty(name.Value))
            {
                where += " and (code like '%" + name.Value + "%' or name like '%" + name.Value + "%')";
            }
            hidwhere.Value = where;
            bindData(hidwhere.Value);
        }
    }
}